import requestService from "../service/request";

const Api = {
  myAddresses: "/wap/commerce/address/myAddresses", // 获取我的地址列表
  addressDetail: "/wap/commerce/address/address", //获取地址详情
  //   address: "/web/commerce/address/address", // 变动类型 /commerce/address/address/{id}
  editAddress: "/wap/commerce/address/editAddress", // 编辑地址
  removeAddress: "/wap/commerce/address/removeAddress", // 删除地址
  position: "/area/areas", // 获取位置
  status: "/wap/commerce/address/setDefaultAddress", //修改地址状态
  area: "/area/areas", // 获取下一级区域
};

export function AddressDetail(data) {
  // 调用requestService函数，传入Api.myAddresses和data作为参数，type为post
  return requestService(Api.addressDetail + "/" + data.id, {
    type: "get",
  });
}
// 导出一个函数，用于获取地址信息
export function getArea(data) {
  // 调用requestService函数，传入Api.myAddresses和data作为参数，type为post
  return requestService(Api.area + "/" + data.parentId, {
    type: "get",
  });
}
// 导出一个函数，用于获取地址信息
export function GetAddresses(data) {
  // 调用requestService函数，传入Api.myAddresses和data作为参数，type为post
  return requestService(Api.myAddresses, {
    type: "post",
    data,
  });
}

export function EditAddress(data) {
  return requestService(Api.editAddress, {
    type: "post",
    data,
  });
}

export function RemoveAddress(data) {
  return requestService(Api.removeAddress, {
    type: "post",
    data,
    paramsFormdata: "application/x-www-form-urlencoded",
  });
}

export function getPosition(data) {
  return requestService(Api.position + "/" + data.parentId, {
    type: "get",
    data,
  });
}
export function updatedStatus(data) {
  return requestService(Api.status, {
    type: "post",
    data,
  });
}
